<html>
<head>
    <script type="text/javascript" src="../libjs/Perl6/MetaModel.js"></script>
    <script type="text/javascript">
        require.INC = "../inc";    
        require('Test.Builder');
        require('Test.More'); 

        require.INC = "../libhs";    
        require('Perl6.MultiMethod');        
        require('Perl6.Method');                
    </script>     
</head>
<body>
<pre id='test'><script type="text/javascript">

plan({ tests : 7 });

var method_1 = new Perl6.Method('Foo', function (inv, args) { return 'arity of 1' }, 1);
isaOK(method_1, 'Perl6.Method');

var method_2 = new Perl6.Method('Foo', function (inv, args) { return 'arity of 2' }, 2);
isaOK(method_2, 'Perl6.Method');

var method_3 = new Perl6.Method('Foo', function (inv, args) { return 'arity of 3' }, 3);
isaOK(method_3, 'Perl6.Method');

var multi = new Perl6.MultiMethod('Foo', [ method_1, method_2, method_3 ]);
isaOK(multi, 'Perl6.MultiMethod');

var inv = 'MyInvocant';
is(multi.call(inv, []), 'arity of 1', '... got the right method for arity of 1');
is(multi.call(inv, [ 'two' ]), 'arity of 2', '... got the right method for arity of 2');
is(multi.call(inv, [ 'two', 'three' ]), 'arity of 3', '... got the right method for arity of 3');

</script></pre>
</body>
</html>
